@extends('admin.layout.global')

@section('css-plugins')
    <link href="{{ asset('style/plugins/bootstrap-switch/css/bootstrap3/bootstrap-switch.min.css') }}" rel="stylesheet">
    <link href="{{ asset('style/plugins/chosen_v1.2.0/chosen.min.css') }}" rel="stylesheet">
@endsection

@section('css')
    <link href="{{ asset('style/admin/css/custom.css') }}" rel="stylesheet">
@endsection

@section('js-plugins')
    <script src="{{ asset('style/plugins/bootstrap-switch/js/bootstrap-switch.min.js') }}"></script>
    <script src="{{ asset('style/plugins/chosen_v1.2.0/chosen.jquery.min.js') }}"></script>
@endsection

@section('js')
    <script src="{{ asset('style/admin/js/pages/blankon.form.element.js') }}"></script>
    <script>
        function leftMove()
        {
            var pageH = $(document.body).height();
            var scrollT = $(window).scrollTop();
            if (scrollT > 65 && scrollT < pageH-$('#leftMove').height()-65)
            {
                var offset = scrollT - 65;
                $('#leftMove').css({"position":"relative" ,"top": offset + "px"});
            } else {
                $('#leftMove').removeAttr('style');
            }
        }
        $(function(){
            $("[type='checkbox']").bootstrapSwitch();

            $(".fa-hover").each(function(){
                $(this).click(function(){
                    var icoclass = $("i",this).attr("class");
                    $("#ico").attr("value",icoclass);
                    $("#icoico").attr("class",icoclass);
                })
            });
            leftMove();
            $(window).scroll(function () {
                leftMove();
            });
        });
    </script>
@endsection

@section('content')
    <div class="body-content animated fadeIn">
        <div class="row">
            <div class="col-md-4">
                <div class="panel rounded shadow" id="leftMove">
                    <div class="panel-heading">
                        <div class="pull-left">
                            <h3 class="panel-title">{{ last($HMENU)->name }}</h3>
                        </div><!-- /.pull-left -->
                        <div class="pull-right">
                        </div><!-- /.pull-right -->
                        <div class="clearfix"></div>
                    </div><!-- /.panel-heading -->
                    <div class="panel-body">
                        <form method="post">
                            <div class="form-body">
                                {!! csrf_field() !!}
                                <div class="form-group">
                                    <label class="control-label">{{ getLang('fieldsMenu', 'parentDir') }}<span class="asterisk">*</span></label>
                                    <select data-placeholder="{{ getLang('fieldsMenu', 'parentDirHelp') }}" name="parentID" class="chosen-select mb-15" tabindex="2">
                                        <option value="0">{{ getLang('fieldsMenu', 'topDir') }}</option>
                                        {!! $tree !!}
                                    </select>
                                </div>
                                <div class="form-group">
                                    <label class="control-label">{{ getLang('fieldsMenu', 'columnName') }}<span class="asterisk">*</span></label>
                                    <input placeholder="{{ getLang('fieldsMenu', 'columnNameHelp') }}" name="name" value="{{ old('name') }}" class="form-control" type="text">
                                    {!! getErrorMsg($errors, 'name') !!}
                                </div>
                                <div class="form-group">
                                    <label class="control-label">{{ getLang('fieldsMenu', 'controller') }}</label>
                                    <input placeholder="{{ getLang('fieldsMenu', 'controllerHelp') }}" name="controller" value="{{ old('controller') }}" class="form-control" type="text">
                                    {!! getErrorMsg($errors, 'controller') !!}
                                </div>
                                <div class="form-group">
                                    <label>{{ getLang('fieldsMenu', 'isShow') }}</label><br>
                                    <input type="checkbox" name="display" checked-false data-size="small" data-on-text="{{ getLang('Tips', 'showON') }}" data-off-text="{{ getLang('Tips', 'showOFF') }}" data-label-width="0" data-on-color="success" data-off-color="danger">
                                </div>
                                <div class="form-group">
                                    <label class="control-label">{{ getLang('Tips', 'sort') }}</label>
                                    <input placeholder="{{ getLang('fieldsMenu', 'sortHelp') }}" name="listOrder" value="{{ old('listOrder') ? old('listOrder') : 0 }}" class="form-control" type="text">
                                    {!! getErrorMsg($errors, 'listOrder') !!}
                                </div>
                                <div class="form-group">
                                    <label>{{ getLang('fieldsMenu', 'icon') }}&nbsp;&nbsp;</label><i id="icoico" class="{{ old('icon') ? old('icon') : '' }}"></i>
                                    <input type="text" name="icon" value="{{ old('icon') ? old('icon') : '' }}" id="ico" class="form-control" placeholder="{{ getLang('fieldsMenu', 'iconHelp') }}">
                                    <p class="help-block">{{ getLang('fieldsMenu', 'iconHelp2') }}</p>
                                </div>
                                <div class="row">
                                    <div class="col-md-6">
                                        <a href="{{ action('Admin\MenuController@getIndex') }}" class="btn btn-warning btn-sm btn-block"><i class="fa fa-reply"></i> <span class="bold">{{ getLang('Tips', 'rollBack') }}</span></a>
                                    </div>
                                    <div class="col-md-6">
                                        <button class="btn btn-primary btn-sm btn-block" type="submit"><i class="fa fa-check"></i>&nbsp;{{ getLang('Tips', 'submit') }}</button>
                                    </div>
                                </div>
                            </div>
                        </form>
                    </div><!-- /.panel-body -->
                </div><!-- /.panel -->
            </div>
            <div class="col-md-8">
                @include('admin.menu-icon')
            </div>
        </div><!-- /.row -->
    </div>
@endsection